<?php
/*
  $Id: invoice.php,v 1.6 2003/06/20 00:37:30 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

$niceinvoicenumber = $order->info['date_purchased'];
$niceinvoicenumber = str_replace(':', '', $niceinvoicenumber);
$niceinvoicenumber = str_replace('-', '', $niceinvoicenumber);
$niceinvoicenumber = str_replace(' ', '', $niceinvoicenumber);

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<style type="text/css">
/* <![CDATA[ */

body {
    color: #676767;
    font-size: 11px;
    font-family: Tahoma, Arial;
}

.title {
    color: #888888;
    font-size: 24px;
    font-weight: bold
}

.titlew {
    color: #bbbbbb;
    font-size: 14px;
    font-weight: bold
}

.titleb {
    color: #888888;
    font-size: 14px;
    font-weight: bold
}

table, td
{
    border-color: #000000;
    border-style: solid;
}

.tablenoborder
{
    border-color: #000000;
    border-style: solid;
    border-width: 0px;
}

.tdnoborder
{
    margin: 0;
    padding: 4px;
    border-width: 0 0 0 0;
    background-color: #ffffff;
}

table
{
    border-width: 0 0 1px 1px;
    border-spacing: 0;
    border-collapse: collapse;
}

td
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
    background-color: #ffffff;
}

/* ]]> */
</style>
</head>
<body>
<br>
<!-- body_text //-->
<table align="center" width="95%" class="tablenoborder">
  <tr>
    <td valign="top" class="tdnoborder" align="right"><img src="<?php echo HTTP_SERVER; ?>/data/images/admin_logo.png"></td>
  </tr>
</table>
<br>
<table align="center" width="95%" class="tablenoborder">
  <tr>
    <td width="50%" valign="top" align="left" class="tdnoborder title">
      <table align="center" width="100%" class="tablenoborder">
        <tr>
          <td class="tdnoborder title"><h1><?php echo STORE_NAME; ?></h1></td>   
        </tr>
        <tr>
          <td class="tdnoborder titlew">Store contact details:</td>   
        </tr>
        <tr>
          <td class="tdnoborder"><?php echo nl2br(STORE_CONTACT_ADDRESS); ?><br></td>
        </tr>
        <tr>
          <td class="tdnoborder titlew">Contact #<br></td>
        </tr>
        <tr>
          <td class="tdnoborder"><?php echo nl2br(STORE_CONTACT_NUMBER); ?></td>   
        </tr>
      </table>
    </td>
    <td width="50%" valign="middle" align="left" class="tdnoborder">
      <table align="center" width="100%" class="tablenoborder">
        <tr>
          <td class="tdnoborder titlew"><nobr>Date:</nobr></td><td class="tdnoborder"><?php echo $order->info['date_purchased']; ?></td>
        </tr>
        <tr>
          <td class="tdnoborder titlew"><nobr>Invoice #</nobr></td><td class="tdnoborder"><? echo $niceinvoicenumber; ?></td>
        </tr>
        <tr>
          <td class="tdnoborder titlew"><nobr>&nbsp;</nobr></td><td class="tdnoborder">&nbsp;</td>
        </tr>
        <tr>
          <td class="tdnoborder titlew" valign="top"><nobr>Sold to:</nobr></td><td class="tdnoborder" align="left"><?php echo tep_address_format($order->customer['format_id'], $order->customer, 1, '', '<br>'); ?></td>
        </tr>
        <tr>
          <td class="tdnoborder titlew"><nobr>Contact #</nobr></td><td class="tdnoborder"><?php echo $order->customer['telephone']; ?></td>
        </tr>
        <tr>
          <td class="tdnoborder titlew"><nobr>Email:</nobr></td><td class="tdnoborder"><?php echo $order->customer['email_address']; ?></td>
        </tr>
      </table>
    </td>  
  </tr>
</table>
<br>
<br>
<table align="center" class="tablenoborder" width="95%">
  <tr>
    <td valign="top" class="tdnoborder"><span class="titlew"><?php echo ENTRY_PAYMENT_METHOD; ?></span>&nbsp;<?php echo $order->info['payment_method']; ?></td>
  </tr>
</table> 
<br>  
<br>
<table align="center" width="93%">
  <tr>
    <td class="titlew">&nbsp;</td>
    <td class="titlew"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
    <td class="titlew"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
    <td class="titlew"><?php echo TABLE_HEADING_TAX; ?></td>
    <td class="titlew"><?php echo TABLE_HEADING_TOTAL_EXCLUDING_TAX; ?></td>
    <td class="titlew"><?php echo TABLE_HEADING_TOTAL_INCLUDING_TAX; ?></td>
  </tr>
<?php
    for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
      echo '<tr>' . "\n" .
           '<td>' . $order->products[$i]['qty'] . '&nbsp;x</td>' . "\n" .
           '<td>' . $order->products[$i]['name'];

      if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
        for ($j = 0; $j < $k; $j++) {
          echo '<br><nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
          if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';
          echo '</i></small></nobr>';
        }
      }

      echo '</td>' . "\n" .
           '<td>' . $order->products[$i]['model'] . '</td>' . "\n";
      echo '<td>' . tep_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n" .
           '<td>' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n" .
           '<td>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n";
      echo '</tr>' . "\n";
    }
?>
</table>
<br>
<br>
<table align="center" width="95%" class="tablenoborder">
  <tr>
    <td width="50%" valign="top" align="left" class="tdnoborder">
    <span class="titlew">Store bank details:</span><br>
    <?php echo nl2br(STORE_BANK_ACCOUNT); ?> 
    </td>
    <td width="50%" valign="top" align="left" class="tdnoborder title">
<table align="center" width="92%" class="tablenoborder">
<?php
  for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
    echo '<tr>' . "\n" .
         '<td class="tdnoborder titlew" width="85%" align="right">' . $order->totals[$i]['title'] . '</td>' . "\n" .
         '<td class="tdnoborder titleb" width="15%"align="right">' . $order->totals[$i]['text'] . '</td>' . "\n" .
         '</tr>' . "\n";
  }
?>
</table>
    </td>
  </tr>
</table>
<!-- body_text_eof //-->

<br>
</body>
</html>
